package com.siysoft.tc.admin.action;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.siysoft.tc.admin.service.IAdminReservationService;
import com.siysoft.util.IMap;



/**
 * <p>Title: AdminReservationController</p>
 * <p>Description:咨询管理功能</p>
 * <p>Company: dmpb</p>
 * @author    victor
 * @date       2015年11月12日
 */
@Controller
@RequestMapping(value = "/admin/reservation")
public class AdminReservationController {
	@Autowired
	IAdminReservationService reservationService;
	
	
	//预约单管理
	@RequestMapping(value = "/toReservation")
	public String toReservation(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		List<Map<String,Object>> seekReservations = reservationService.seekReservations(iMap);
		request.setAttribute("reservationList", seekReservations);
		return "/admin/reservation/reservationList";
	}
	
	//预约单管理
	@RequestMapping(value = "/toReservationApprove")
	public String toReservationApprove(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		List<Map<String,Object>> seekReservations = reservationService.seekReservationsApprove(iMap);
		request.setAttribute("reservationList", seekReservations);
		return "/admin/reservation/reservationListApprove";
	}
	
	//预约单管理
	@RequestMapping(value = "/toReservationAdmin")
	public String toReservationAdmin(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		List<Map<String,Object>> seekReservations = reservationService.seekReservationsAdmin(iMap);
		request.setAttribute("reservationList", seekReservations);
		return "/admin/reservation/reservationListAdmin";
	}
	
	// 跳转修改学生信息页面
	@RequestMapping(value = "/toReservationRevise")
	public String toStuRevise(HttpServletRequest request) throws Exception {
		IMap iMap = new IMap(request);
		Map<String, String> stuRevise = reservationService.toReservationRevise(iMap);
		request.setAttribute("rs", stuRevise);
		if(iMap.getString("type") == null){
			return "/admin/reservation/reservationRevise";
		}
		else if(iMap.getString("type").equals("admin")){
			return "/admin/reservation/reservationReviseAdmin";
		}
		else if(iMap.getString("type").equals("approve")){
			return "/admin/reservation/reservationReviseApprove";
		}
		return "/admin/reservation/reservationRevise";
	}

	// 修改学生信息
	@RequestMapping(value = "/reservationRevise")
	public String stuRevise(HttpServletRequest request) throws Exception {
		IMap iMap = new IMap(request);
		reservationService.reviseReservationInfo(iMap);
		
		if(iMap.getString("type") == null){
			return "redirect:/admin/reservation/toReservation.htm";
		}
		else if(iMap.getString("type").equals("approve")){
			return "redirect:/admin/reservation/toReservationApprove.htm";
		}
		else if(iMap.getString("type").equals("admin")){
			return "redirect:/admin/reservation/toReservationAdmin.htm";
		}
		return "redirect:/admin/reservation/toReservation.htm";
	}
	
	//上课记录
	@RequestMapping(value = "/toUserReservation")
	public String toUserReservation(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		List<Map<String,Object>> seekReservations = reservationService.seekReservations(iMap);
		request.setAttribute("reservationList", seekReservations);
		return "/admin/reservation/reservationList";
	}
	

	
}
